package com.ddwl.goods.service.bargain;

import com.ddwl.common.util.BeanConverUtils;
import com.ddwl.common.util.MySqlUtil;
import com.ddwl.goods.dao.bargain.BargainLogDao;
import com.ddwl.goods.model.bargain.BargainLog;
import com.ddwl.schema.bo.base.PageBo;
import com.ddwl.schema.bo.goods.bargain.BargainLogPageBo;
import com.ddwl.schema.vo.base.PageVo;
import com.ddwl.schema.vo.goods.bargain.BargainLogVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author hemiaojun
 * @Date 2020/10/26 11:45
 */
@Service
public class BargainLogService {

    @Resource
    private BargainLogDao bargainLogDao;




    public PageVo<BargainLogVo> page(PageBo<BargainLogPageBo> pageBo) {
        PageHelper.startPage(pageBo.getPage(), pageBo.getPageSize(), MySqlUtil.orderBy(pageBo.getSort(), pageBo.isAsc()));
        PageInfo<BargainLog> info = new PageInfo<>(bargainLogDao.getList(pageBo.getParam()));
        List<BargainLogVo> list = BeanConverUtils.convertBeanList(info.getList(), BargainLogVo.class);
        return new PageVo<>(info.getTotal(), pageBo.getPage(), pageBo.getPageSize(), list);
    }
}
